package com.yylending.las.repay.repayrecord;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.Loader;
import android.widget.TextView;

import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Presenter;
import com.yyfax.infrastructure.mvp.PresenterLoader;
import com.yylending.las.R;
import com.yylending.las.base.BaseActivity;
import com.yylending.las.common.widgets.CustomGridLayoutManager;
import com.yylending.las.common.widgets.TotalDisplayRecycleView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 还款计划 or 还款记录 (需求修改, 暂时未用到, 改为了还款详情页面:{@link com.yylending.las.repay.repaydetail.RepayDetailActivity}, 此类及相关的类先保留)
 * Created by ying_he on 2017/6/5.<br>
 * Copyright  2017 www.yylending.com. All Rights Reserved.<br><br>
 */
public class RepayPlanOrHistoryActivity extends BaseActivity implements RepayPlanOrHistoryPresenter.View {

    private static final int LOADER_ID = 1;

    @BindView(R.id.loan_sum_tv)
    TextView mLoanSumTv;
    @BindView(R.id.interest_expenses_tv)
    TextView mInterestExpensesTv;
    @BindView(R.id.total_should_pay_tv)
    TextView mTotalShouldPayTv;
    @BindView(R.id.repay_type_tv)
    TextView mRepayTypeTv;
    @BindView(R.id.early_payoff_tv)
    TextView mEarlyPayoffTv;
    @BindView(R.id.repay_rv)
    TotalDisplayRecycleView mRepayRv;

    private RepayPlanOrHistoryPresenter mPresenter;
    private RepayPlanOrHistoryAdapter mAdapter;

    public static void start(Activity aty) {
        Intent intent = new Intent(aty, RepayPlanOrHistoryActivity.class);
        aty.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_repay_plan_or_history);
        EventAgent.register(this);
        ButterKnife.bind(this);
        initData();
    }

    private void initData() {
        setTitle(R.string.repayment_plan);
        setTitle(R.string.repay_history);
        CustomGridLayoutManager LayoutManager = new CustomGridLayoutManager(this, 1);
        LayoutManager.setScrollEnabled(false);
        mRepayRv.setLayoutManager(LayoutManager);
        mAdapter = new RepayPlanOrHistoryAdapter();
        mRepayRv.setAdapter(mAdapter);
    }

    @Override
    public void onLoadFinished(Loader<Presenter> loader, Presenter data, int placeholder) {
        mPresenter = (RepayPlanOrHistoryPresenter) data;
        mPresenter.attach(this);
        requestData();
    }

    @Override
    public Loader<Presenter> onCreateLoader(int id, Bundle args) {
        return new PresenterLoader<>(this, new RepayPlanOrHistoryPresenter.Generator());
    }

    @Override
    protected void onStart() {
        super.onStart();
        getSupportLoaderManager().initLoader(LOADER_ID, null, this);
    }

	@Override
	protected void onStop() {
		getSupportLoaderManager().destroyLoader(LOADER_ID);
		super.onStop();
	}

	@Override
    protected void onDestroy() {
        super.onDestroy();
    }

    private void requestData() {

    }
}
